// pages/user/insComm/insComm.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  formSubmit: function(e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
    console.log(e.detail.value.CommInput)
    var resid = app.comresid
    console.log(resid)
    var date = new Date();
    if ((date.getMonth() + 1) <= 9) {
      if (date.getDate <= 9) {
        var resDate = date.getFullYear() + "-0" + (date.getMonth() + 1) + "-0" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
      } else {
        var resDate = date.getFullYear() + "-0" + (date.getMonth() + 1) + "-0" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
      }
    } else {
      if (date.getDate <= 9) {
        var resDate = date.getFullYear() + (date.getMonth() + 1) + "-0" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
      } else {
        var resDate = date.getFullYear() + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
      }
    }
    console.log(resDate)
    wx.request({
      url: 'http://localhost:8889/reverse/saveComm',
      data:{
        id: resid,
        comTime: resDate,
        comment: e.detail.value.CommInput
      },
      success:function(res){
        if(res.data){
          wx.showModal({
            title: '提示',
            content: '保存评论信息成功',
            showCancel: false,
            success: function (res) {
              if (res.confirm) {
                wx.redirectTo({
                  url: '../plwfcomment/plwfcomment'
                })

              }
            }
          })
        }
      }
    })
  },
  navtocomm:function(e){
    console.log(e)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})